/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.googlecode.j4sc.submission.manager;


/**
 * The Strategies class is a convenience class for setting the
 * {@link RetrievalStrategy} to use with the {@link SubmissionManager}. It
 * offers either a {@link Strategies#BASIC} strategy which configures the
 * {@link BasicRetrievalStrategy} with a max attempts of 20 resulting is an
 * expiry of 20 minutes or the {@link Strategies#PROGRESSIVE} strategy which
 * configures the {@link ProgressiveRetrievalStrategy} with a max attempts of 5
 * resulting in expiry after 16 minutes.
 * <p>
 * Example usage shown below
 * 
 * <pre>
 * SubmissionManager manager = new SubmissionManager(Service.LIVE, Strategies.BASIC);
 * </pre>
 * 
 * @author Raj Patel, Dariusz Lorenc
 */
public class Strategies {

    private static final int PROGRESSIVE_MAX_ATTEMPTS = 5;
    private static final int BASIC_MAX_ATTEMPTS = 20;
    
    /**
     * A {@link BasicRetrievalStrategy} which polls every minute for a maximum
     * of 20 minutes
     */
    public static final RetrievalStrategy BASIC = new BasicRetrievalStrategy(BASIC_MAX_ATTEMPTS);
    /**
     * A {@link ProgressiveRetrievalStrategy} which polls on 1, 2, 4, 8, and 16
     * minutes before expiring a message
     */
    public static final RetrievalStrategy PROGRESSIVE = new ProgressiveRetrievalStrategy(PROGRESSIVE_MAX_ATTEMPTS);
    
    private Strategies() {
        // should not be constructed
    }
}
